package com.jy.oms.framework.asyn.task.constants;

/**
 * 任务状态
 */
public enum TaskStateEnum {
    /**
     * 待处理
     */
    UNDO(0),
    /**
     * 完成
     */
    DONE(1),
    /**
     * 错误
     */
    ERROR(2),
    /**
     * 超时
     */
    TIMEOUT(3),
    /**
     * 无效任务
     */
    INVALID(99);

    private Integer code;

    TaskStateEnum(Integer code) {
        this.code = code;
    }

    public static boolean between(Integer code, TaskStateEnum... states) {
        if (code == null || states == null) {
            return false;
        }

        for (TaskStateEnum state : states) {
            if (code.equals(state.getCode())) {
                return true;
            }
        }
        return false;
    }

    public Integer getCode() {
        return code;
    }
}
